<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
	<composite:attribute name="updateElement" />
	<composite:attribute name="oncomplete" />
</composite:interface>

<composite:implementation>
	<p:dataTable id="clientesTableID" var="cliente"
		value="#{clientesMB.clientes}" rowKey="#{cliente.id}"
		selectionMode="single" emptyMessage="No se han encontrado clientes"
		filteredValue="#{clientesMB.clientesFiltrados}"
		rowsPerPageTemplate="5,10,15"
		styleClass="table table-striped table-bordered"
		selection="#{clientesMB.selectedCliente}"
		rowStyleClass="#{cliente.state == 1 ?  null: 'danger'}">

		<p:ajax event="rowSelect" listener="#{clientesMB.rowSelected}"
			update="clientesTableID" />

		<p:column id="numCol" filterBy="#{cliente.numero}" headerText="Numero"
			filterMatchMode="contains">
			<h:outputText value="#{cliente.numero}" />
		</p:column>
		<p:column id="nombreCol" filterBy="#{cliente.nombre}"
			headerText="Nombre" filterMatchMode="contains">
			<h:outputText value="#{cliente.nombre}" />
		</p:column>
		<f:facet name="footer">
			<p:commandButton id="selectButton" value="Seleccionar"
				disabled="#{!clientesMB.rowSelected}" icon="ui-icon-arrowthick-1-n"
				oncomplete="#{cc.attrs.oncomplete}" />
		</f:facet>
	</p:dataTable>
</composite:implementation>

</html>